import { useRef, useState, useCallback } from 'react'

const usePopup = () => {
  const fromRef = useRef(null)
  const [visible, setVisible] = useState(false)

  const openPopup = useCallback(() => setVisible(true), [])
  const closePopup = useCallback(() => setVisible(false), [])

  return {
    fromRef,
    visible,
    openPopup,
    closePopup,
  }
}

export default usePopup
